<?php
class Data_test extends basicdata_test
{
    const typeCompare = 'compare';
    const typeError = 'error';
    const typeValue = 'value';
    
    public static function saveNew($idTest, $type, $key, $value1, $value2 = null){
        $model = self::loadModel();
        $model->id_test = $idTest;
        $model->type = $type;
        $model->keyV = $key;
        $model->value1 = $value1;
        $model->value2 = $value2;
        $model->id_data_set = 0;
        
        $model->save();
    }
    
    public static function getOneValues($idTest, $type){
        return self::getValues($idTest, $type, 1);
    }
    
    public static function getTwoValues($idTest, $type){
        return self::getValues($idTest, $type, 2);
    }
    protected static function getValues($idTest, $type, $valuesNum = 1)
    {
        $array = self::getAll("where id_test = '$idTest' and type='$type'");
        $values = array();
        foreach($array as $model){
            if($valuesNum == 1)
                $values[] = Array($model->keyV, $model->value1);
            else 
                $values[] = Array($model->keyV, $model->value1, $model->value2);
        }
        return $values;
    }
   

}
?>